﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类UserSigningCenterRelation 的摘要说明。
    /// </summary>
    public class UserSigningCenterRelation
    {
        public UserSigningCenterRelation()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.UserSigningCenterRelation model)
        {
            Chenxin.Lib.Business.DAL.UserSigningCenterRelation.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.UserSigningCenterRelation model)
        {
            Chenxin.Lib.Business.DAL.UserSigningCenterRelation.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {

            Chenxin.Lib.Business.DAL.UserSigningCenterRelation.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.UserSigningCenterRelation GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Business.DAL.UserSigningCenterRelation.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.UserSigningCenterRelation.GetList(strWhere);
        }

        public List<Chenxin.Lib.Business.Entity.UserSigningCenterRelation> GetListByCenterId(string CenterId)
        {
            string strWhere = string.Format("CenterId = '{0}'", CenterId);
            return GetModelList(strWhere);
        }

        //*******************************************
        //功能概要       ：根据参数列表获得签约中心人员列表
        //参数説明       ：hsParams 参数列表
        //返回值説明     ：无
        //功能詳細       ：根据参数列表获得签约中心人员列表
        //作成者         ：he.jifeng 
        //作成日         ：2010-07-12
        //*******************************************
        public DataSet GetListByConditions(System.Collections.Hashtable hsParams)
        {

            //order文
            string OrderField = " T_UserSigningCenterRelation.SignerName ";
            //select文
            string FieldList = " RecordId,CenterId,CenterName,SignerId,SignerName,BelongCityId,BelongCityName,BelongCompanyId,BelongCompanyName,BelongDepartId,BelongDepartName ";
            string TableFieldList = " RecordId,CenterId,CenterName,SignerId,SignerName,BelongCityId,BelongCityName,BelongCompanyId,BelongCompanyName,BelongDepartId,BelongDepartName ";
            //表名
            string TableName = "T_UserSigningCenterRelation";

            //当前页数
            int PageIndex = 1;
            //显示行数
            int PageSize = 15;
            //where文
            System.Text.StringBuilder strWhere = new System.Text.StringBuilder();
            strWhere.AppendFormat(" CenterId='{0}' ", hsParams["CenterId"]);

            //当前页数
            if (hsParams.ContainsKey("pageIndex"))
            {
                PageIndex = Convert.ToInt32(hsParams["pageIndex"]);
            }
            //显示行数
            if (hsParams.ContainsKey("pageSize"))
            {
                PageSize = Convert.ToInt32(hsParams["pageSize"]);
            }

            DataSet ds = Chenxin.Lib.Business.DAL.UserSigningCenterRelation.GetList(PageSize, PageIndex,
                                                                                    OrderField, TableName,
                                                                                    strWhere.ToString(), FieldList,
                                                                                    TableFieldList, true);
            return ds;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.UserSigningCenterRelation> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.UserSigningCenterRelation.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.UserSigningCenterRelation> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.UserSigningCenterRelation> modelList = new List<Chenxin.Lib.Business.Entity.UserSigningCenterRelation>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.UserSigningCenterRelation model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.UserSigningCenterRelation();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["CenterId"].ToString() != "")
                    {
                        model.CenterId = new Guid(dt.Rows[n]["CenterId"].ToString());
                    }
                    model.CenterName = dt.Rows[n]["CenterName"].ToString();
                    if (dt.Rows[n]["SignerId"].ToString() != "")
                    {
                        model.SignerId = new Guid(dt.Rows[n]["SignerId"].ToString());
                    }
                    model.SignerName = dt.Rows[n]["SignerName"].ToString();
                    if (dt.Rows[n]["BelongDepartId"].ToString() != "")
                    {
                        model.BelongDepartId = new Guid(dt.Rows[n]["BelongDepartId"].ToString());
                    }
                    model.BelongDepartName = dt.Rows[n]["BelongDepartName"].ToString();
                    if (dt.Rows[n]["BelongCompanyId"].ToString() != "")
                    {
                        model.BelongCompanyId = new Guid(dt.Rows[n]["BelongCompanyId"].ToString());
                    }
                    model.BelongCompanyName = dt.Rows[n]["BelongCompanyName"].ToString();
                    if (dt.Rows[n]["BelongCityId"].ToString() != "")
                    {
                        model.BelongCityId = new Guid(dt.Rows[n]["BelongCityId"].ToString());
                    }
                    model.BelongCityName = dt.Rows[n]["BelongCityName"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  成员方法
    }
}

